home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright 1995 Ogasawara Hiroyuki(COR.)
- */
-
- #include <corlib.h>
- #include <sys_doslib.h>
-
- #include "Sesse.inc"
-
- #define PROG "GV_Rev v1.10"
-
- #define GVIEWWIN "gview.win"
- #define XSIZE 80
- #define YSIZE 42
-
- int WindowHeapSize= 1024*0;
-
- static void
- WaitMark()
- {
- MouseSetPattern( 1, &SessePattern, 7, 3 );
- MS_SEL( 1 );
- }
-
- static void
- MakeNewGWin( ng, gp )
- UGraphic *ng, *gp;
- {
- EventInfo info;
- ng->palet= gp->palet;
- ng->color= gp->color;
- info.option= EventUser;
- info.ComBuffer= ng;
- info.ComData= UserGraphic;
- PidSendEvent( GVIEWWIN, &info, TRUE );
- MFREE( ng->buf );
- }
-
- GV_Rot( gp )
- UGraphic *gp;
- {
- UGraphic ng;
- WaitMark();
- if( gp->color == WindowAttrGraphic65536 ){
- unsigned short *str= MALLOC( gp->h*gp->v*2 ),
- *ptr= gp->buf;
- int x, y;
- if( (int)(ng.buf= str) < 0 )
- return FALSE;
- for( y= 0 ; y< gp->h ; y++ ){
- for( x= gp->v-1 ; x >= 0 ; x-- )
- *str++= ptr[x*gp->h +y];
- }
- }else{
- unsigned char *str= MALLOC( gp->h*gp->v ),
- *ptr= (void*)gp->buf;
- int x, y;
- if( (int)(ng.buf= (void*)str) < 0 )
- return FALSE;
- for( y= 0 ; y< gp->h ; y++ ){
- for( x= gp->v-1 ; x >= 0 ; x-- )
- *str++= ptr[x*gp->h +y];
- }
- }
- ng.h= gp->v;
- ng.v= gp->h;
- MakeNewGWin( &ng, gp );
- MS_SEL( 0 );
- return TRUE;
- }
-
- GV_Rev( gp, mode )
- UGraphic *gp;
- {
- EventInfo info;
- UGraphic ng;
- WaitMark();
- if( gp->color == WindowAttrGraphic65536 ){
- unsigned short *str= MALLOC( gp->h*gp->v*2 ),
- *ptr= gp->buf;
- int x, y;
- if( (int)(ng.buf= str) < 0 )
- return FALSE;
- if( mode ){
- for( y= gp->v-1 ; y>= 0 ; y-- ){
- for( x= 0 ; x < gp->h ; x++ )
- *str++= ptr[y*gp->h+ x];
- }
- }else{
- for( y= 0 ; y < gp->v ; y++ ){
- for( x= gp->h-1 ; x>= 0 ; x-- )
- *str++= ptr[y*gp->h+ x];
- }
- }
- }else{
- unsigned char *str= MALLOC( gp->h*gp->v ),
- *ptr= (void*)gp->buf;
- int x, y;
- if( (int)(ng.buf= (void*)str) < 0 )
- return FALSE;
- if( mode ){
- for( y= gp->v-1 ; y>= 0 ; y-- ){
- for( x= 0 ; x < gp->h ; x++ )
- *str++= ptr[y*gp->h+ x];
- }
- }else{
- for( y= 0 ; y < gp->v ; y++ ){
- for( x= gp->h-1 ; x>= 0 ; x-- )
- *str++= ptr[y*gp->h+ x];
- }
- }
- }
- ng.h= gp->h;
- ng.v= gp->v;
- MakeNewGWin( &ng, gp );
- MS_SEL( 0 );
- return TRUE;
- }
-
-
- static int
- EventExec( wp, info )
- WindowID wp;
- EventInfo *info;
- {
- DrawBuf dbuf[4];
- switch( info->option ){
- case EventOpen:
- WindowSetEventAttr( wp, EventOpenON|EventRedrawON
- |EventCloseON|EventMouseSwitchON|EventIconifyON
- |EventUserON );
- WindowRedraw( wp );
- return TRUE;
- case EventIconify:
- IconEnt( wp, PROG, AttrDefault, 12 );
- return TRUE;
- case EventRedraw:
- DrawSetClear( dbuf, ColorGray );
- DrawSetSymbol( dbuf+1, 3, 1, PROG, 9|4, 12 );
- DrawSetSymbol( dbuf+2, 3,14, "[回転][↑↓]", 9, 12 );
- DrawSetSymbol( dbuf+3, 3,26, "------[←→]", 9, 12 );
- WindowDraw( wp, dbuf, 4 );
- return TRUE;
- case EventClose:
- WindowClose( wp );
- WindowConnectionClose();
- return TRUE;
- case EventUser:
- switch( info->ComData ){
- case UserGraphic:
- if( info->y >= 30+14 )
- GV_Rev( info->ComBuffer, 0 );
- else if( info->x < XSIZE/2 )
- GV_Rot( info->ComBuffer );
- else
- GV_Rev( info->ComBuffer, 1 );
- return TRUE;
- case UserString:
- case UserPaste:
- case UserStrings:
- break;
- }
- return FALSE;
-
- case EventMouseSwitch:
- if( info->LeftON ){
- ConsoleOpen();
- ConsolePrint(
- "\r\n" PROG " 1995 COR.\r\n"
- "------------------------------------------------------------------------\r\n"
- "16/256/65536色画像データを上下左右反転、または 90度回転を行います。入出\r\n"
- "力は EventUser の UserGraphic で行います。出力に gview.win が必要です。\r\n"
- "------------------------------------------------------------------------\r\n"
- );
- return TRUE;
- }
- return FALSE;
- }
- return FALSE;
- }
-
-
- void
- WindowMain( argc, argv )
- char **argv;
- {
- int x= 300, y= 0;
- argc= AnalyzeArgs( argc, argv, &x, &y, NULL, NULL );
- WindowTitleOpen( x, y, XSIZE, YSIZE, NULL, " ",
- Close|Push|Icon, EventExec );
- }
-
-